public class work2 {
    public int[] productExceptSelf(int[] nums) {
        int n=nums.length;
        int []qdp=new int[n];
        int []hdp=new int[n];
        qdp[0]=1;
        for (int i = 1; i <=n-1 ; i++) {
            qdp[i]=qdp[i-1]*nums[i-1];
        }
        hdp[n-1]=1;
        for(int i=n-2;i>=0;i--){
            hdp[i]=hdp[i+1]*nums[i+1];
        }
        int []arr=new int[n];
        for (int i = 0; i <n ; i++) {
            arr[i]=qdp[i]*hdp[i];
        }
        return arr;
    }
}
